package com.mianshi.java01;

import com.mianshi.java01.entity.*;

public class FruitStore {
    public static void main(String[] args) {
        // 定义购买各水果的斤数
        int appleQuantity;
        int strawberryQuantity;
        int mangoQuantity;

        // 测试顾客A
        // 定义顾客A购买苹果的斤数
        appleQuantity = 2;
        // 定义顾客A购买草莓的斤数
        strawberryQuantity = 3;
        Customer customerA = new Customer("A");
        customerA.addToCart(new Apple(), appleQuantity);
        customerA.addToCart(new Strawberry(false), strawberryQuantity);
        Cashier cashierA = new Cashier(false);
        double totalA = cashierA.calculateTotal(customerA);
        System.out.println("顾客A的总价: " + totalA + " 元");
        System.out.println("验证结果: " + (totalA == (appleQuantity * 8 + strawberryQuantity * 13)));
        System.out.println();

        // 测试顾客B
        // 定义顾客B购买苹果的斤数
        appleQuantity = 2;
        // 定义顾客B购买草莓的斤数
        strawberryQuantity = 4;
        // 定义顾客B购买芒果的斤数
        mangoQuantity = 2;
        Customer customerB = new Customer("B");
        customerB.addToCart(new Apple(), appleQuantity);
        customerB.addToCart(new Strawberry(false), strawberryQuantity);
        customerB.addToCart(new Mango(), mangoQuantity);
        Cashier cashierB = new Cashier(false);
        double totalB = cashierB.calculateTotal(customerB);
        System.out.println("顾客B的总价: " + totalB + " 元");
        System.out.println("验证结果: " + (totalB == (appleQuantity * 8 + strawberryQuantity * 13 + mangoQuantity * 20)));
        System.out.println();

        // 测试顾客C
        // 定义顾客C购买苹果的斤数
        appleQuantity = 2;
        // 定义顾客C购买草莓的斤数
        strawberryQuantity = 3;
        // 定义顾客C购买芒果的斤数
        mangoQuantity = 1;
        Customer customerC = new Customer("C");
        customerC.addToCart(new Apple(), appleQuantity);
        customerC.addToCart(new Strawberry(true), strawberryQuantity);
        customerC.addToCart(new Mango(), mangoQuantity);
        Cashier cashierC = new Cashier(false);
        double totalC = cashierC.calculateTotal(customerC);
        System.out.println("顾客C的总价: " + totalC + " 元");
        System.out.println("验证结果: " + (totalC == (appleQuantity * 8 + strawberryQuantity * 13 * 0.8 + mangoQuantity * 20)));
        System.out.println();

        // 测试顾客D
        // 定义顾客D购买苹果的斤数
        appleQuantity = 3;
        // 定义顾客D购买草莓的斤数
        strawberryQuantity = 4;
        // 定义顾客D购买芒果的斤数
        mangoQuantity = 2;
        Customer customerD = new Customer("D");
        customerD.addToCart(new Apple(), appleQuantity);
        customerD.addToCart(new Strawberry(true), strawberryQuantity);
        customerD.addToCart(new Mango(), mangoQuantity);
        Cashier cashierD = new Cashier(true);
        double totalD = cashierD.calculateTotal(customerD);
        System.out.println("顾客D的总价: " + totalD + " 元");
        // 验证结果
        // 未进行满减时顾客D购买水果的价钱
        double totalD1 = appleQuantity * 8 + strawberryQuantity * 13 * 0.8 + mangoQuantity * 20;
        // 进行满减时顾客D购买水果的价钱
        double totalD2 = totalD1 - Math.floor( totalD1 / 100) * 10;
        System.out.println("验证结果: " + (totalD == totalD2));
    }
}
